/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbrew.openbrewrf.views;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "PurchaseOrder")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PurchaseOrderView.findOpenPOs", query = "SELECT p FROM PurchaseOrderView p WHERE p.pOState != '30'"),
    @NamedQuery(name = "PurchaseOrderView.findClosedPOs", query = "SELECT p FROM PurchaseOrderView p WHERE p.pOState = '30'"),
    @NamedQuery(name = "PurchaseOrderView.getAllUnExported", query = "SELECT s FROM PurchaseOrderView s WHERE s.exported = false"),
    @NamedQuery(name = "PurchaseOrderView.getAllExported", query = "SELECT s FROM PurchaseOrderView s WHERE s.exported = true")})
public class PurchaseOrderView implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "POID")
    private Integer poid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PODate")
    @Temporal(TemporalType.DATE)
    private Date pODate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "exported")
    private boolean exported;
    @Basic(optional = false)
    @NotNull
    @Column(name = "POState")
    private int pOState;

    public PurchaseOrderView() {
    }

    public PurchaseOrderView(Integer poid) {
        this.poid = poid;
    }

    public PurchaseOrderView(Integer poid, Date pODate, boolean exported, int pOState) {
        this.poid = poid;
        this.pODate = pODate;
        this.exported = exported;
        this.pOState = pOState;
    }

    public Integer getPoid() {
        return poid;
    }

    public void setPoid(Integer poid) {
        this.poid = poid;
    }

    public Date getpODate() {
        return pODate;
    }

    public void setpODate(Date pODate) {
        this.pODate = pODate;
    }

    public boolean isExported() {
        return exported;
    }

    public void setExported(boolean exported) {
        this.exported = exported;
    }

    public int getpOState() {
        return pOState;
    }

    public void setpOState(int pOState) {
        this.pOState = pOState;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (poid != null ? poid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PurchaseOrderView)) {
            return false;
        }
        PurchaseOrderView other = (PurchaseOrderView) object;
        if ((this.poid == null && other.poid != null) || (this.poid != null && !this.poid.equals(other.poid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.PurchaseOrderView[ poid=" + poid + " ]";
    }
}
